package com.xbongbong.paas.service.field.impl;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.NumericalLimitsPoJo;
import com.xbongbong.paas.service.field.FieldOptimizationService;
import com.xbongbong.paas.toolbox.exception.XbbException;

import java.util.Objects;

/**
 * @author：吴峰
 * @date：2020/07/13 11:00
 */
public class NumOptimizationServiceImpl extends BaseOptimization implements FieldOptimizationService {



    @Override
    public void execute(FieldAttrEntity entity) throws XbbException {
        removeAddRuleAndRemoveRule(entity);
        removeItems(entity);
        removeOfImageAndFile(entity);
        removeDateType(entity);
        removeLineType(entity);
        if (Objects.isNull(entity.getAccuracy())) {
            entity.setAccuracy(0);
        }
        if (Objects.equals(1, entity.getNumericalLimitsFlag()) && Objects.isNull(entity.getNumericalLimits())) {
            // 避免前端没初始化，后端增加初始化
            entity.setNumericalLimits(new NumericalLimitsPoJo());
        }
        removeDetailAddress(entity);
        removeOfHideField(entity);
        commonHandle(entity);
    }
}
